package com.yl.danmo.controller;


import com.yl.common.core.utils.poi.ExcelUtil;
import com.yl.common.core.web.controller.BaseController;
import com.yl.common.core.web.domain.AjaxResult;
import com.yl.common.log.annotation.Log;
import com.yl.common.log.enums.BusinessType;
import com.yl.common.security.annotation.RequiresPermissions;
import com.yl.danmo.domain.DanmoImage;
import com.yl.danmo.service.IDanmoImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 图片信息Controller
 * 
 * @author yl
 * @date 2025-04-12
 */
@RestController
@RequestMapping("/danmoImage")
public class DanmoImageController extends BaseController
{
    @Autowired
    private IDanmoImageService danmoImageService;

    /**
     * 查询图片信息列表
     */
//    @RequiresPermissions("system:danmoImage:list")
    @GetMapping("/list")
    public List<DanmoImage> list(DanmoImage danmoImage)
    {

        List<DanmoImage> list = danmoImageService.selectDanmoImageList(danmoImage);
        return list;
    }

    /**
     * 导出图片信息列表
     */
//    @RequiresPermissions("system:danmoImage:export")
    @Log(title = "图片信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoImage danmoImage)
    {
        List<DanmoImage> list = danmoImageService.selectDanmoImageList(danmoImage);
        ExcelUtil<DanmoImage> util = new ExcelUtil<DanmoImage>(DanmoImage.class);
        util.exportExcel(response, list, "图片信息数据");
    }

    /**
     * 获取图片信息详细信息
     */
//    @RequiresPermissions("system:danmoImage:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(danmoImageService.selectDanmoImageById(id));
    }

    /**
     * 新增图片信息
     */
//    @RequiresPermissions("system:danmoImage:add")
    @Log(title = "图片信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DanmoImage danmoImage)
    {
        return toAjax(danmoImageService.insertDanmoImage(danmoImage));
    }

    /**
     * 修改图片信息
     */
//    @RequiresPermissions("system:danmoImage:edit")
    @Log(title = "图片信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DanmoImage danmoImage)
    {
        return toAjax(danmoImageService.updateDanmoImage(danmoImage));
    }

    /**
     * 删除图片信息
     */
//    @RequiresPermissions("system:danmoImage:remove")
    @Log(title = "图片信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoImageService.deleteDanmoImageByIds(ids));
    }





}
